export class ActivityStatus {
    static readonly WAIT_PUBLISH = new ActivityStatus(100, '待发布');
    static readonly PUBLISH = new ActivityStatus(110, '发布');
    static readonly WAIT_AUDIT = new ActivityStatus(200, '待审核');
    static readonly AUDITING = new ActivityStatus(210, '审核中');
    static readonly AUDIT_PASS = new ActivityStatus(220, '审核通过');
    static readonly AUDIT_FAIL = new ActivityStatus(230, '审核不通过');
    static readonly READY = new ActivityStatus(300, '活动就绪');
    static readonly START = new ActivityStatus(310, '活动开始');
    static readonly EXECUTING = new ActivityStatus(320, '活动执行中');
    static readonly PAUSE = new ActivityStatus(410, '暂停状态');
    static readonly RECOVER = new ActivityStatus(420, '恢复状态');
    static readonly DELAY = new ActivityStatus(510, '延期状态');
    static readonly END = new ActivityStatus(900, '活动结束');
    static readonly CANCEL = new ActivityStatus(910, '活动取消');

    private constructor(public readonly status: number, public readonly text: string) {
    }

    private static readonly values = [
        ActivityStatus.WAIT_PUBLISH,
        ActivityStatus.PUBLISH,
        ActivityStatus.WAIT_AUDIT,
        ActivityStatus.AUDITING,
        ActivityStatus.AUDIT_PASS,
        ActivityStatus.AUDIT_FAIL,
        ActivityStatus.READY,
        ActivityStatus.START,
        ActivityStatus.EXECUTING,
        ActivityStatus.PAUSE,
        ActivityStatus.RECOVER,
        ActivityStatus.DELAY,
        ActivityStatus.END,
        ActivityStatus.CANCEL
    ];

    static getText(status: number): string {
        const activityStatus = ActivityStatus.values.find(item => item.status === status);
        if (!activityStatus) {
            throw new Error(`Invalid status code: ${status}`);
        }
        return activityStatus.text;
    }

    static getStatus(text: string): number {
        const activityStatus = ActivityStatus.values.find(item => item.text === text);
        if (!activityStatus) {
            throw new Error(`Invalid text: ${text}`);
        }
        return activityStatus.status;
    }

    static getAllStatuses(): ActivityStatus[] {
        return [...ActivityStatus.values];
    }
}
// // Usage examples:
// console.log(ActivityStatus.getText(100)); // Output: '待发布'
// console.log(ActivityStatus.getStatus('发布')); // Output: 110
// console.log(ActivityStatus.getAllStatuses()); // Output: Array of all ActivityStatus instances
